package cn.com.w.common.VO;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author w
 * @Description:
 * @DateTime: 2025 04 25 10:14
 **/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class BaseVO<T> {
    /**
     * 返回码
     */
    private Integer code;
    /**
     * 消息
     */
    private String message;
    /**
     * 数量
     */
    private Long count;
    /**
     * 内容
     */
    private T content;

    /**
     * 错误消息
     */
    private String error;

    public BaseVO(T content) {
        this.content = content;
    }

    public static <T> BaseVO<Object> success(T msg) {
        return BaseVO.builder()
                .code(0)
                .content(msg)
                .message("成功")
                .build();
    }

    public static void error(String msg) throws Exception {
        throw new Exception(msg);
    }
}

